<?php

class Core_Validate_Uri extends Zend_Validate_Abstract
{
	const MSG_URI = 'invalidURI';

	protected $_messageTemplates = array(
		self::MSG_URI => "Invalid URI",
	);

	public function isValid($value)
	{
		$parts = explode('.', $value);
		
		if (sizeof($parts) > 1)
		{
			if (strlen($parts[sizeof($parts) - 1]) > 1)
			{
				if (strpos($value, 'http') !== 0)
				{
					$value = 'http://' . $value;
				}
			}
		}
		
		$this->_setValue($value);

		$valid = Zend_Uri::check($value);

		if (!$valid)
		{
			$this->_error(self::MSG_URI);
			return false;
		}
		
		return true;
	}

}